package com.yz.ssm.controller;

import com.yz.ssm.pojo.User;
import com.yz.ssm.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by apple on 2017/8/24.
 */
@Controller
public class UserController {

    @RequestMapping("/hello/{name}")
    public String index(@PathVariable("name") String name,Model model){
        model.addAttribute("name",name);
        return "/hello";
    }


    @Resource
    private UserService userService;
    @RequestMapping("/user/{userId}")
    @ResponseBody
    public User in(@PathVariable("userId") Integer userId){
        return userService.findUserById(userId);
    }
}
